<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '佣金管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="jjr-user-commission-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('创建佣金', ['create-self'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            [ 'attribute'=>'real_name','label'=>'经纪人'],
            [ 'attribute'=>'name','label'=>'项目名称'],
            [ 'attribute'=>'client_real_name','label'=>'客户名称'],
            // 'jjr_user_project_id',
            [ 'attribute'=>'amount','label'=>'金额'],
            [ 'attribute'=>'transfer_status','label'=>'结佣状态','value'=>function($model){
                if($model['transfer_status']==\backend\models\JjrUserCommission::TRANSFER_NOT_START){
                    return '未结佣';
                }else if($model['transfer_status']==\backend\models\JjrUserCommission::TRANSFER_STARTED){
                    return '结佣中';
                }else if($model['transfer_status']==\backend\models\JjrUserCommission::TRANSFER_END){
                    return '已结佣';
                }else if($model['transfer_status']==\backend\models\JjrUserCommission::TRANSFER_FAIL){
                    return '结佣失败';
                }
            }],

            [ 'attribute'=>'create_time','label'=>'创建时间'],

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>

<!-- 定义数据块 -->
<?php $this->beginBlock('test'); ?>
jQuery(document).ready(function() {
highlight_subnav('jjr-user-commission/index'); //子导航高亮
});
<?php $this->endBlock() ?>
<!-- 将数据块 注入到视图中的某个位置 -->
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>
